﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using DotConferenceSql;
using NUnit.Framework.SyntaxHelpers;

namespace TestDotConferenceSql
{
    [TestFixture]
    public class TestGroupByQueryElement
    {
        SqlQuery query;
        GroupByQueryElement groupElement;

        [SetUp]
        public void Init()
        {
            query = new SqlQuery();
            groupElement = new GroupByQueryElement();

            query.Elements.Add(groupElement);
        }

        [Test]
        public void BasicGroupByQuery()
        {
            groupElement.Add("field1");
            groupElement.Add("field2");
            groupElement.Add("field3");

            Assert.That(query.BuildTextQuery(), Text.Contains("GROUP BY field1,field2,field3"));
        }

        [Test]
        public void GroupByUsingAddRange()
        {
            groupElement.AddRange(new string[] { "field1", "field2", "field3" });

            Assert.That(query.BuildTextQuery(), Text.Contains("GROUP BY field1,field2,field3"));
        }
    }
}
